import tkinter as tk

root = tk.Tk()
root.geometry("500x300+100+100")
text = tk.Text(root, width=30, height=10)

text.pack()
text.insert(tk.INSERT, "hello world ! \n")

b1 = tk.Button(root, text='获取数据', )
b1.pack()
b2 = tk.Button(root, text='插入数据', )
b2.pack()
b3 = tk.Button(root, text='删除数据', )
b3.pack()

b4 = tk.Button(root, text='获取光标位置', )
b4.pack()


def get_text():
    print(text.get(0.0, tk.END))


def insert_text():
    print(text.insert(tk.END, 'hello world !'))


def delete_text():
    print(text.delete(1.0, '1.end'))


def text_cursor():
    print(tk.INSERT)


b1.config(command=get_text)
b2.config(command=insert_text)
b3.config(command=delete_text)
b4.config(command=text_cursor)

root.mainloop()
